<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加或编辑界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
    <style>
        .w440 {width:340px !important;}
        .cy-uploadpic-ctn{margin-bottom:0!important;}
    </style>
</head>
<body>
<div class="page-content-wrap clearfix">
    <form class="layui-form" id="tool">
        <div class="layui-tab">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;名称：</label>
                        <div class="layui-input-inline w440">
                            <input type="text" name="name" value="${wxApplyVo.name}" lay-verify="required" placeholder="请输入名称" autocomplete="off"
                                   class="layui-input" maxlength="200">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;封面：</label>
                        <!--单图片开始-->
                        <div class="layui-input-block cy-uploadpic-ctn" id="coverImage" style=" float:left;margin-left:0!important;position:relative;"></div>
                        <!--单图片结束-->
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;延长到期时间：</label>
                        <div class="layui-input-inline w440">
                            <input type="text" name="useDay" value="0" lay-verify="required|number" placeholder="请输入延长到期时间" autocomplete="off"
                                   class="layui-input" maxlength="11">
                        </div>
                    </div>
                    <#if applyId == null || applyId ==''>
                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;公众号：</label>
                        <div class="layui-input-inline w440">
                            <select name="accountId" id="accountId">
                                <option value="">请选择(默认不修改)</option>
                                <#list wxAccountList as p>
                                <#if p.id == wxApplyVo.accountId>
                                <option value="${p.id}" selected>${p.name}</option>
                                <#else>
                                <option value="${p.id}">${p.name}</option>
                                </#if>
                                </#list>
                            </select>
                        </div>
                    </div>
                    </#if>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;状态：</label>
                        <div class="layui-input-inline w440">
                            <select name="status" id="status" lay-verify="required"></select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-pop-btn">
            <div class="layui-input-block" style="margin-left: 0px !important;text-align: center">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">提交</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                <button type="button" style="display: none;" id="save" class="layui-btn layui-btn-primary"></button>
            </div>
        </div>
    </form>
</div>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'page', 'fileUtil', 'baseutil'], function () {
        var $ = layui.jquery,
            form = layui.form,
            page = layui.page,
            fileUtil = layui.fileUtil,
            baseutil = layui.baseutil;

        //初始化附件控件
        fileUtil.uploadImage('coverImage', "wx/wxApplyVo", "${wxApplyVo.coverImage}");

        page.initDict('base_status', function (dictData) {
            page.showDict($("#status"), page.aceeptDictContentList(dictData, 'base_status'), "请选择", '${wxApplyVo.status}');
        });

        //监听提交
        form.on('submit(submitBtn)', function (data) {
            data.field.id = '${wxApplyVo.id}';
            baseutil.post("/wx/wxapply/addOrUpdate", data.field, function () {
                $("#save").click();
            });
            return false;
        });
    })
    ;
</script>
</body>
</html>